package com.youku.controls
{
   import com.youku.plugins.programListV4.ProgramListFacade;
   import com.youku.GlobalService;
   import com.youku.GlobalServiceKeys;
   import com.youku.events.PluginEvent;
   import com.youku.interfaces.IProgramData;
   import com.youku.events.PlayerControlEvent;
   import com.youku.data.PlayerConstant;
   
   public class ProgramListV4Controller extends BasePluginController
   {
      
      public function ProgramListV4Controller() {
         super();
         this.init();
      }
      
      private var _programListFacade:ProgramListFacade;
      
      override protected function init() : void {
         this._programListFacade = ProgramListFacade.getInstance();
         this._programListFacade.init(viewManager.controlsLayer,playerProxy);
         GlobalService.addService(GlobalServiceKeys.PROGRAMLIST_FACADE,this._programListFacade);
         playerProxy.addEventListener(PluginEvent.PROGRAMLIST_VIDEO_CLICK,this.onProgramListEvent);
         playerProxy.addEventListener(PluginEvent.PROGRAMLIST_CLOSE_CLICK,this.onProgramListEvent);
      }
      
      private function onProgramListEvent(param1:PluginEvent) : void {
         var _loc2_:IProgramData = null;
         switch(param1.type)
         {
            case PluginEvent.PROGRAMLIST_VIDEO_CLICK:
               _loc2_ = param1.data as IProgramData;
               facadeManager.tryToPlayProgram(_loc2_);
               break;
            case PluginEvent.PROGRAMLIST_CLOSE_CLICK:
               playerProxy.dispatchEvent(new PlayerControlEvent(PlayerControlEvent.AFTER_CLOSE_PANELS,{"panel":PlayerConstant.PANEL_PROGRAM_LIST}));
               break;
         }
      }
   }
}
